package com.algorithm.string_and_array;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;

@Slf4j
public class DoublePointerSolutionLC05 {
    public int findMaxConsecutiveOnes(int[] nums) {
        int tmp = 0;
        int sum = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == 1) {
                tmp++;
            } else {
                tmp = 0;
            }
            sum = tmp >= sum ? tmp : sum;
        }

        return sum;
    }

    @Test
    public void test(){
        int [] nums = {1,1,0,1,1,1};
        int ones = findMaxConsecutiveOnes(nums);
        log.info("the times is {}",ones);
    }
}
